﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sunny.UI;
using Communicate;
using System.Threading;
using System.IO;
namespace OtherDevice
{
    [Description("服务器")]
    public partial class Frm_Server : Form_ControlBase
    {
        object obj = new object();
        SocketSever socketSever = null;
        public Frm_Server()
        {
            InitializeComponent();
        }
        public override void FlushToDlg(object devicebase)
        {
            try
            {
                if (devicebase == null)
                    return;
                this.socketSever = devicebase as SocketSever;
                this.Dock = DockStyle.Fill;
                this.Show();
            }
            catch (Exception)
            {

            }

        }
        public void RecvStringMessageDelegate(string strMsg)
        {
            if (InvokeRequired)
            {
                this.BeginInvoke(new Action(() => RecvStringMessageDelegate(strMsg)));
            }
            else
            {
                list_ShowMeg.Items.Add(strMsg);
                list_ShowMeg.SelectedIndex = list_ShowMeg.Items.Count - 1;
            }
        }

        private void btn_Send_Click(object sender, EventArgs e)
        {
            try
            {
                socketSever.Send(txt_SendMsg.Text);

            }
            catch (Exception ex)
            {
                UIMessageBox.ShowError(ex.Message);
            }

        }
    }
}
